; ORIGINAL: 3dt2.1/examples/entlist.scm
; $Id: entlist.scm,v 1.4 1997/04/30 20:24:09 jread Exp $
; --------------------------------------------------------------------------
;  Procedure: ENTLIST.SCM
;      Notes: Tests a data object to determine if it is an entity or a
;             list of entities.  Includes a general procedure for checking
;             an object of any data type.
; --------------------------------------------------------------------------

; Purpose: Checks if data object is an entity.
;
(define is-entity? (lambda (ent)
    (type-of entity? ent)
    ))

; Purpose: Checks if a data object is a list of entities.
;
(define is-entity-list? (lambda (ent_list)
    (list-of entity? ent_list)
    ))

; Purpose: General object type checking.
;
(define type-of (lambda (type_proc type_obj)
    (type_proc type_obj)
    ))

; Purpose: General object type list checking.
;
(define list-of (lambda (type_proc type_list)
    (if (list? type_list)
        (if (null? type_list)
            #f
            ; walk the list looking for data type
            (list-helper type_proc type_list)
            )
        #f)
    ))

; Purpose: Uses recursion to help the previos procedure and is
;          separated for readability.
;
(define list-helper (lambda (type_proc type_list)
    (if (type_proc (car type_list))
        (if (list? (cdr type_list))
            (if (null? (cdr type_list))
                #t
                (list-helper type_proc (cdr type_list))
                )
            #f)
        #f)
    ))

; ----------------------------------
;  End of ENTLIST.SCM
; ----------------------------------













